
cmake_minimum_required(VERSION 2.8)

project (graphics)

cmake_policy(SET CMP0015 OLD)

#set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_GENERATOR_TOOLSET "v110_xp" CACHE STRING "Platform Toolset" FORCE) 
#set(CMAKE_VS_PLATFORM_TOOLSET "v110_xp" CACHE STRING "Platform Toolset" FORCE)

macro(source_group_by_dir source_files)
    if(MSVC)
        set(sgbd_cur_dir ${CMAKE_CURRENT_SOURCE_DIR})
        foreach(sgbd_file ${${source_files}})
            string(REGEX REPLACE ${sgbd_cur_dir}/\(.*\) \\1 sgbd_fpath ${sgbd_file})
            string(REGEX REPLACE "\(.*\)/.*" \\1 sgbd_group_name ${sgbd_fpath})
            string(COMPARE EQUAL ${sgbd_fpath} ${sgbd_group_name} sgbd_nogroup)
            string(REPLACE "/" "\\" sgbd_group_name ${sgbd_group_name})
            if(sgbd_nogroup)
                set(sgbd_group_name "\\")
            endif(sgbd_nogroup)
            source_group(${sgbd_group_name} FILES ${sgbd_file})
        endforeach(sgbd_file)
    endif(MSVC)
endmacro(source_group_by_dir)

INCLUDE_DIRECTORIES(
	lib/SDL2-2.0.3/include
	src
)


LINK_DIRECTORIES(
	${PROJECT_SOURCE_DIR}/lib/SDL2-2.0.3/lib/x86
)

set(CMAKE_CXX_FLAGS_RELEASE "/MD")
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")

add_definitions(-DUNICODE -D_UNICODE)

file(GLOB_RECURSE share_h src/share/*.h)
file(GLOB_RECURSE share_cpp src/share/*.cpp)

##########################################################
# 如果要在解决方案添加新项目，先在src里创建一个test2目录
# 放置一个cpp文件，然后复制下面这段内容
# 并将t1和T1改为T2，重新编译项目或者重新cmake即可
# 以后t3 t4 以此类推
##########################################################

file(GLOB_RECURSE project_t1_headers src/*.h)
file(GLOB_RECURSE project_t1_cpps src/*.cpp)
set (SRC_T1_LIST ${project_t1_headers} ${project_t1_cpps} ${share_h} ${share_cpp})

source_group_by_dir(SRC_T1_LIST)

add_executable(test1 ${SRC_T1_LIST})
target_link_libraries (test1 SDL2main SDL2)

##########################################################
